home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / FROMUTS / CDUNGEON / !CDUNGEON / c / DGAME < prev    next >
Text File  |  1991-05-20  |  5KB  |  262 lines

  1. /* GAME- MAIN COMMAND LOOP FOR DUNGEON */
  2.  
  3. /*COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142*/
  4. /* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
  5. /* WRITTEN BY R. M. SUPNIK */
  6.  
  7. #include <stdio.h>
  8. #include "funcs.h"
  9. #include "vars.h"
  10.  
  11. /* Do all systems have <string.h>?  Don't use it, just in case */
  12.  
  13. extern int strcmp P((const char *, const char *));
  14.  
  15. static logical xvehic_ P((integer));
  16. static void xendmv_ P((logical));
  17.  
  18. void game_()
  19. {
  20.     /* Local variables */
  21.     logical f;
  22.     integer i;
  23.  
  24. /* START UP, DESCRIBE CURRENT LOCATION. */
  25.  
  26.     rspeak_(1);
  27. /*                         !WELCOME ABOARD. */
  28.     f = rmdesc_(3);
  29. /*                         !START GAME. */
  30.  
  31. /* NOW LOOP, READING AND EXECUTING COMMANDS. */
  32.  
  33. L100:
  34.     play_1.winner = aindex_1.player;
  35. /*                         !PLAYER MOVING. */
  36.     play_1.telflg = FALSE_;
  37. /*                         !ASSUME NOTHING TOLD. */
  38.     if (prsvec_1.prscon <= 1) {
  39.     rdline_(input_1.inbuf, 1);
  40.     }
  41.  
  42. #ifdef ALLOW_GDT
  43.  
  44.     if (strcmp(input_1.inbuf + prsvec_1.prscon - 1, "GDT") == 0) {
  45. /*                         !CALL ON GDT? */
  46.     gdt_();
  47. /*                         !YES, INVOKE. */
  48.     goto L100;
  49. /*                         !ONWARD. */
  50.     }
  51.  
  52. #endif /* ALLOW_GDT */
  53.  
  54.     ++state_1.moves;
  55.     prsvec_1.prswon = parse_(input_1.inbuf, 1);
  56.     if (! prsvec_1.prswon) {
  57.     goto L400;
  58.     }
  59. /*                         !PARSE LOSES? */
  60.     if (xvehic_(1)) {
  61.     goto L400;
  62.     }
  63. /*                         !VEHICLE HANDLE? */
  64.  
  65.     if (prsvec_1.prsa == vindex_1.tellw) {
  66.     goto L2000;
  67.     }
  68. /*                         !TELL? */
  69. L300:
  70.     if (prsvec_1.prso == oindex_1.valua || prsvec_1.prso == oindex_1.every) {
  71.     goto L900;
  72.     }
  73.     if (! vappli_(prsvec_1.prsa)) {
  74.     goto L400;
  75.     }
  76. /*                         !VERB OK? */
  77. L350:
  78.     if (! findex_1.echof && play_1.here == rindex_1.echor) {
  79.     goto L1000;
  80.     }
  81.     f = rappli_(rooms_1.ractio[play_1.here - 1]);
  82.  
  83. L400:
  84.     xendmv_(play_1.telflg);
  85. /*                         !DO END OF MOVE. */
  86.     if (! lit_(play_1.here)) {
  87.     prsvec_1.prscon = 1;
  88.     }
  89.     goto L100;
  90.  
  91. L900:
  92.     valuac_(oindex_1.valua);
  93.     goto L350;
  94. /* GAME, PAGE 3 */
  95.  
  96. /* SPECIAL CASE-- ECHO ROOM. */
  97. /* IF INPUT IS NOT 'ECHO' OR A DIRECTION, JUST ECHO. */
  98.  
  99. L1000:
  100.     rdline_(input_1.inbuf, 0);
  101.     ++state_1.moves;
  102. /*                         !CHARGE FOR MOVES. */
  103.     if (strcmp(input_1.inbuf, "ECHO") != 0)
  104.     goto L1300;
  105.  
  106.     rspeak_(571);
  107. /*                         !KILL THE ECHO. */
  108.     findex_1.echof = TRUE_;
  109.     objcts_1.oflag2[oindex_1.bar - 1] &= ~ SCRDBT;
  110.     prsvec_1.prswon = TRUE_;
  111. /*                         !FAKE OUT PARSER. */
  112.     prsvec_1.prscon = 1;
  113. /*                         !FORCE NEW INPUT. */
  114.     goto L400;
  115.  
  116. L1300:
  117.     prsvec_1.prswon = parse_(input_1.inbuf, 0);
  118.     if (! prsvec_1.prswon || prsvec_1.prsa != vindex_1.walkw) {
  119.     goto L1400;
  120.     }
  121.     if (findxt_(prsvec_1.prso, play_1.here)) {
  122.     goto L300;
  123.     }
  124. /*                         !VALID EXIT? */
  125.  
  126. L1400:
  127.     more_output(input_1.inbuf);
  128.     play_1.telflg = TRUE_;
  129. /*                         !INDICATE OUTPUT. */
  130.     goto L1000;
  131. /*                         !MORE ECHO ROOM. */
  132. /* GAME, PAGE 4 */
  133.  
  134. /* SPECIAL CASE-- TELL <ACTOR>, NEW COMMAND */
  135. /* NOTE THAT WE CANNOT BE IN THE ECHO ROOM. */
  136.  
  137. L2000:
  138.     if ((objcts_1.oflag2[prsvec_1.prso - 1] & ACTRBT) != 0) {
  139.     goto L2100;
  140.     }
  141.     rspeak_(602);
  142. /*                         !CANT DO IT. */
  143.     goto L350;
  144. /*                         !VAPPLI SUCCEEDS. */
  145.  
  146. L2100:
  147.     play_1.winner = oactor_(prsvec_1.prso);
  148. /*                         !NEW PLAYER. */
  149.     play_1.here = advs_1.aroom[play_1.winner - 1];
  150. /*                         !NEW LOCATION. */
  151.     if (prsvec_1.prscon <= 1) {
  152.     goto L2700;
  153.     }
  154. /*                         !ANY INPUT? */
  155.     if (parse_(input_1.inbuf, 1)) {
  156.     goto L2150;
  157.     }
  158. L2700:
  159.     i = 341;
  160. /*                         !FAILS. */
  161.     if (play_1.telflg) {
  162.     i = 604;
  163.     }
  164. /*                         !GIVE RESPONSE. */
  165.     rspeak_(i);
  166. L2600:
  167.     play_1.winner = aindex_1.player;
  168. /*                         !RESTORE STATE. */
  169.     play_1.here = advs_1.aroom[play_1.winner - 1];
  170.     goto L350;
  171.  
  172. L2150:
  173.     if (aappli_(advs_1.aactio[play_1.winner - 1])) {
  174.     goto L2400;
  175.     }
  176. /*                         !ACTOR HANDLE? */
  177.     if (xvehic_(1)) {
  178.     goto L2400;
  179.     }
  180. /*                         !VEHICLE HANDLE? */
  181.     if (prsvec_1.prso == oindex_1.valua || prsvec_1.prso == oindex_1.every) {
  182.     goto L2900;
  183.     }
  184.     if (! vappli_(prsvec_1.prsa)) {
  185.     goto L2400;
  186.     }
  187. /*                         !VERB HANDLE? */
  188. /* L2350: */
  189.     f = rappli_(rooms_1.ractio[play_1.here - 1]);
  190.  
  191. L2400:
  192.     xendmv_(play_1.telflg);
  193. /*                         !DO END OF MOVE. */
  194.     goto L2600;
  195. /*                         !DONE. */
  196.  
  197. L2900:
  198.     valuac_(oindex_1.valua);
  199. /*                         !ALL OR VALUABLES. */
  200.     goto L350;
  201.  
  202. } /* game_ */
  203.  
  204. /* XENDMV-    EXECUTE END OF MOVE FUNCTIONS. */
  205.  
  206. /* DECLARATIONS */
  207.  
  208. static void xendmv_(flag)
  209. logical flag;
  210. {
  211.     /* Local variables */
  212.     logical f;
  213.  
  214.     if (! (flag)) {
  215.     rspeak_(341);
  216.     }
  217. /*                         !DEFAULT REMARK. */
  218.     if (hack_1.thfact) {
  219.     thiefd_();
  220.     }
  221. /*                         !THIEF DEMON. */
  222.     if (prsvec_1.prswon) {
  223.     fightd_();
  224.     }
  225. /*                         !FIGHT DEMON. */
  226.     if (hack_1.swdact) {
  227.     swordd_();
  228.     }
  229. /*                         !SWORD DEMON. */
  230.     if (prsvec_1.prswon) {
  231.     f = clockd_();
  232.     }
  233. /*                         !CLOCK DEMON. */
  234.     if (prsvec_1.prswon) {
  235.     f = xvehic_(2);
  236.     }
  237. /*                         !VEHICLE READOUT. */
  238. } /* xendmv_ */
  239.  
  240. /* XVEHIC- EXECUTE VEHICLE FUNCTION */
  241.  
  242. /* DECLARATIONS */
  243.  
  244. static logical xvehic_(n)
  245. integer n;
  246. {
  247.     /* System generated locals */
  248.     logical ret_val;
  249.  
  250.     /* Local variables */
  251.     integer av;
  252.  
  253.     ret_val = FALSE_;
  254. /*                         !ASSUME LOSES. */
  255.     av = advs_1.avehic[play_1.winner - 1];
  256. /*                         !GET VEHICLE. */
  257.     if (av != 0) {
  258.     ret_val = oappli_(objcts_1.oactio[av - 1], n);
  259.     }
  260.     return ret_val;
  261. } /* xvehic_ */
  262.